const express = require("express")

const app = express()

app.use((req, res, next) => {
    console.log("调用了第一个全局中间件");
    next()
})

app.use((req, res, next) => {
    console.log("调用了第二个全局中间件");
    next()
})

const mv1 = function (req, res, next) {
    console.log("调用了局部中间件1");
    next()
}
const mv2 = function (req, res, next) {
    console.log("调用了局部中间件2");
    next()
}
app.get("/", (req, res) => {
    res.send("GET   /")
})

//局部中间件的使用
app.get("/user", mv1, function (req, res) {
    res.send("wangcheng")
})
//多个局部中间件的使用
app.get("/add", [mv1, mv2], function (req, res) {
    res.send("wangcheng")
})
app.listen(8080)